package com.derbysoft.lowcostadapter.web.action.model;

import com.derbysoft.lowcostadapter.commons.exception.InputErrorException;
import com.derbysoft.lowcostadapter.commons.model.RoomStay;
import com.derbysoft.lowcostadapter.commons.redis.utils.KeyValueHelper;
import org.apache.commons.lang.StringUtils;

/**
 * Created by: jason
 * Date: 2012-09-26
 */
public class RoomStayCondition {
    private String propertyId;
    private String roomTypeId;
    private String start;
    private String end;

    public String getPropertyId() {
        return propertyId;
    }

    public void setPropertyId(String propertyId) {
        this.propertyId = propertyId;
    }

    public String getRoomTypeId() {
        return roomTypeId;
    }

    public void setRoomTypeId(String roomTypeId) {
        this.roomTypeId = roomTypeId;
    }

    public String getStart() {
        return start;
    }

    public void setStart(String start) {
        this.start = start;
    }

    public String getEnd() {
        return end;
    }

    public void setEnd(String end) {
        this.end = end;
    }

    public String makeKey() {
        return RoomStay.PREFIX + KeyValueHelper.SEPARATOR + getPropertyId() + KeyValueHelper.SEPARATOR + getRoomTypeId();
    }

    public void validate() {
        if (StringUtils.isBlank(propertyId) || StringUtils.isBlank(roomTypeId)) {
            throw new InputErrorException("Required fields can not be empty !");
        }
    }
}
